home *** CD-ROM | disk | FTP | other *** search
- (*
- CRUSH 0.81 - Public Release
- Designed and created by Bill Davidson
-
- NOTE : Please view the documentation. This program will not execute
- properly without a preset file name.
-
- This is Freeware. Please distribute.
-
- *)
-
- uses dos, crt; { Standard procedure that I always add }
-
-
- const VIIImax = 100;
- VIImax = 100;
- VImax = 100;
- Vmax = 100; { Defining the array limits }
- IVmax = 100;
- IIImax = 100;
- theoffset = 145;
-
- type VIIIarray = array[1..VIIImax] of string[8];
- VIIarray = array[1..VIImax] of string[7];
- VIarray = array[1..VImax] of string[6];
- Varray = array[1..Vmax] of string[5]; { Defining the arrays }
- IVarray = array[1..IVmax] of string[4];
- IIIarray = array[1..IIImax] of string[3];
- chrarray = array[1..6] of char;
-
- const
- VIIIlist: VIIIarray = (' ',' of the ','@ ','--------',' in the ',' pointer','tion of ',' to the ','tructure',
- 'structur','@@~ ','ing the ',' structu','haracter','e of the','lgorithm','characte',' process',
- 'that the',' charact',' that th','@@ ',' program','compress','s of the','rocessor','language',
- 'pointers','algorith','program ',' languag',' can be ',' for the','for the ','ation of','function',
- ' compres','epresent','@Figure ',' on the ','hat the ',' algorit','represen','entation','mplement',
- 'and the ','ormation','formatio',' the pro',' recursi',' functio',' and the','ubprogra',' represe',
- 'subprogr','ion of t','implemen','ompressi','n of the','on of th','nformati','________','ocessor ',
- ' example','ructures',' subprog','rom the ',' from th','from the','t of the','with the','pression',
- 'of the s',' impleme','@@@@@@@@',' with th','position','variable','ould be ',' number ','mpressio',
- 'pointer ','nstructi','ictionar','omponent',' is the ','dictiona','ctionary','putation','consider',
- 'componen','processo','ointers ','ed in th','ith the ','computat','mputatio','umber of','truction',
- 'database');
-
- VIIlist: VIIarray = (' ',' of the','of the ','@ ','_______','in the ',' in the',' which ','to the ',' to the',
- 'program','ion of ','pointer','tion of',' pointe','ing the','tructur','ructure','ng the ','@@ ',
- '@@~ ','@~ ','s that ','e of th',' the co','process','present','at the ','aracter','lgorith',
- 'gorithm','anguage','and the','that th','ompress',' the st','hat the','can be ','s of th',' that t',
- 'e that ',' string','ations ','Figure ','rogram ','or the ','for the',' for th',' scheme',' can be',
- 'on the ','ointers',' the pr','ocessor','nd the ',' follow','@Figure',' on the','ation o',' number',
- ' to be ',' and th','unction',' compre','recursi','the pro',' the re','ntation','nstruct','. The ',
- 'mplemen',' sub i%','plement',' other ','formati','tional ','tation ','rmation',' comput',' recurs',
- 'n of th','es the ','rom the',' there ','with th','t of th','from th',' would ',' repres','on of t',
- '-------',' first ','example','@@@@@@@',' subpro','mpressi','.@This ',' from t','cessor ','ould be');
-
- VIlist: VIarray = (' ',' of th',' that ','f the ',' the s','@ ','ation ',' the c','s the ','in the',' this ',
- 'e the ',' in th','which ','______',' point','t the ',' with ','struct','to the',' which',' the p',
- 'rogram','o the ',' to th','@@ ','ion of','tions ','ing th','tion o','pointe','on of ','ointer',
- '.@The ','rocess','ations','tation','s are ','at the','ction ',', and ','s that',' the f','s and ',
- 'ructur',' proce','the co','ucture','r the ',' have ','~ ','g the ','d the ','@~ ','e of t',
- ' will ',' the t','nd the','string',' the l','and th','lement','ed by ','ed to ',' struc','presen',
- ' the a','ed in ','resent','e that',' the r','other ',' the r','other ',' the n',' sub i','hat th',
- 'racter','gorith','orithm','that t','can be','the st','ection',' The ','or the',' other','nguage',
- 'mpress','s of t',' the o','there ',' the e','for th','an be ','on the','Figure',' of a ','------',
- '. The ');
-
- Vlist: Varray = (' ',' the ',' and ','tion ','ation','of th',' of t',' that','f the','that ','@ ','n the',' sub ',
- 'ction','s of ',' for ','the s',' comp','s the',' are ','the c','e the','e of ','tions',' with','in th',
- 't the','ing t',' this','this ','which','with ',' in t','point',' the@','inter','to th','hich ','_____',
- 'the p','ther ','truct','o the','.@The','@The ',' to t','struc','@the ','here ','s to ','ion o','ions ',
- 't of ','@and ','@@ ','ting ',' not ','ng th','ogram','ition','n of ','t is ','d the','on of','ement',
- ' from',' can ','from ','other','ointe',' cont','progr',' of a','s are',' one ','at th','ed in','ding ',
- 'he co','e is ','r the','g the','proce','ocess','d to ',', and','ould ',' is a','cture','s and','the f',
- ', the','ing a','nd th',' have','s tha','and t','have ','will ',' The ');
-
- IVlist: IVarray = (' ',' the','the ',' of ','tion','ing ','and ',' to ',' and',' is ','ion ',' in ','that','f th',' tha',
- 'atio','hat ','of t','n th',' sub','@ ','s th',' for','e th','his ',' pro','ther',' com','for ',' be ',
- ' con','sub ','s of','he s','comp','The ','are ',' are','he c','t th','with','ent ','e of','ions',' thi',
- 'e co','ment','.@Th','in t','ted ','inte','@the','nter','this','@The',' wit','ng t','ter ','here',' as ',
- 'mple','o th','her ','ith ','pres','@and',' str','hich','ting','to t','oint',' not','d th','he p','the@',
- 'ere ','ding','ring',' by ','s a ',' it ','____','ich ',' whi','s to','s in','cess','form','s an','t th',
- 'is a','gram','ed t','ture','one ','t of',' poi','t is','----','oice');
-
- IIIlist: IIIarray = (' ',' th','the','he ',' of','of ','ing','ion','is ','and','tio',' an','nd ',' in','ed ',' to','to ',
- 'ng ',' co','er ','on ','es ',' a ','re ',' is','ent','in ','s a','e t','or ','ter',' re',' su','at ',
- 's t','for',' be','ati','@@~','hat','tha','e s','e a','n t','al ','her','f t','res','pro','e c',' fo',
- ' pr','s o',' st','e o','as ','sub','. ','all','en ','on ','con','are','ess','his','ly ','e i','The',
- 'ch ',' no','@ ','t t','ith','omp','ons','int','nte','ll ',' ar','ere',' de','cti','be ','ver','nt ',
- 'st ','d t','ers',' wi',' wh','str','e p','nce','ts ',' ma','ate','@th','thi','---','. T');
-
- chrlist: chrarray = (chr(1),chr(2),chr(3),chr(4),chr(5),chr(6));
-
- { Those arrays make up the dictionoary that I use to code with }
-
- var
- f, j : text;
- s,s1 : string[255];
- a1, v1 : integer;
- c1 : string[2];
- find1,find2,find3 : integer;
- length1 : integer;
- chra : integer;
- label
- skipdouble,startloop,
- skip8,skip7,skip6,skip5,skip4,skip3,start8,start7,start6,start5,start4,start3,end1;
-
- begin
- assign(f,'q.q'); { File to compress }
- reset(f); { Open the file to compress for reading}
- assign(j,'w.w'); { Output file }
- rewrite(j); { Open the output file for writing }
- while not eof(f) do { if we have not reached the end of the file... }
- begin
-
- readln(f,s); { Read the current line }
- length1 := length(s);
- for chra := 249 to 254 do { Trying to find header characters }
- begin
- a1 := 0; { pointer to the string position }
- startloop:
- a1 := a1 + 1; { Advance pointer }
- if a1 > length1 then goto end1; { Check to see if we have reached the
- end of the line }
- begin
- if chr(chra) = s[a1] then { If current scanned character equals
- a header character then... }
- begin
- insert(chr(chra),s,a1); { Insert another header character with
- it }
- a1 := a1 + 1; { Advance pointer past the doubled
- character }
- length1 := length(s);
- end;
- goto startloop;
- end;
- end1:
- end;
-
- for v1 := 1 to VIIImax do { Using the 8 letter array }
- begin
- start8:
- a1 := pos(VIIIlist[v1],s); { Searching the line for each of the
- strings in the array and moves the
- pointer there }
- if a1 = 0 then goto skip8; { Skip this if it doesn't find any }
- delete(s,a1,length(VIIIlist[v1])); { Delete the string at the pointer }
- c1 := chr(249) + chr(v1 + theoffset); { The header character and a code
- character for the string }
- insert(c1,s,a1); { Insert the 2 characters }
- goto start8;
- skip8:
- end;
-
- { It's the same for 7 to 3 }
-
- for v1 := 1 to VIImax do
- begin
- start7:
- a1 := pos(VIIlist[v1],s);
- if a1 = 0 then goto skip7;
- delete(s,a1,length(VIIlist[v1]));
- c1 := chr(250) + chr(v1 + theoffset);
- insert(c1,s,a1);
- goto start7;
- skip7:
- end;
-
- for v1 := 1 to VImax do
- begin
- start6:
- a1 := pos(VIlist[v1],s);
- if a1 = 0 then goto skip6;
- delete(s,a1,length(VIlist[v1]));
- c1 := chr(251) + chr(v1 + theoffset);
- insert(c1,s,a1);
- goto start6;
- skip6:
- end;
-
- for v1 := 1 to Vmax do
- begin
- start5:
- a1 := pos(Vlist[v1],s);
- if a1 = 0 then goto skip5;
- delete(s,a1,length(Vlist[v1]));
- c1 := chr(252) + chr(v1 + theoffset);
- insert(c1,s,a1);
- goto start5;
- skip5:
- end;
-
- for v1 := 1 to IVmax do
- begin
- start4:
- a1 := pos(IVlist[v1],s);
- if a1 = 0 then goto skip4;
- delete(s,a1,length(IVlist[v1]));
- c1 := chr(253) + chr(v1 + theoffset);
- insert(c1,s,a1);
- goto start4;
- skip4:
- end;
-
- for v1 := 1 to IIImax do
- begin
- start3:
- a1 := pos(IIIlist[v1],s);
- if a1 = 0 then goto skip3;
- delete(s,a1,length(IIIlist[v1]));
- c1 := chr(254) + chr(v1 + theoffset);
- insert(c1,s,a1);
- goto start3;
- skip3:
- end;
- length1 := length(s);
- writeln(j,s); { Write the modified string to the output file }
- end;
- close(j); { Save 'j' }
- end.
-